<template>
	<!-- 定位失败 -->
	<div class="abs">
		<div id="dingwei" @click="goMap">
			<span class="iconfont icon-location"></span>
			{{prov}}
		</div>
		<div>
			<span class="iconfont icon-diqiu"></span>
			必游榜单
		</div>
	</div>
</template>

<script>
	import BMap from 'BMap'
	// 2.在各组件中引入xx.js文件
	import Pub from '../public.js'
	export default {
		data() {
			el: "dingwei"
			return {
				prov: "加载中..."

			}
		},
		mounted() {
			this.ready()
		},
		methods: {
			ready() {
				const geolocation = new BMap.Geolocation();
				var _this = this
				geolocation.getCurrentPosition(function getinfo(position) {
					var city = position.address.city; //获取城市信息        
					var province = position.address.province;
					_this.prov = city
				// 在A组件中通过$emit 调用自定义函数并传参
					Pub.$emit('getBmapCity',city)
				}, function(e) {
					alert("获取百度定位位置信息失败");
				}, {
					provider: 'baidu',
				});
			},
			goMap(){
				this.$router.push('Map')
			}
		}
	}
</script>

<style scoped>
	.abs {
		width: 100%;
		display: flex;
		border-top: .01rem solid #e0e0e0;
		box-sizing: border-box;
		background: white;
	}
	.abs div:nth-child(2)::before {
		content: '';
		height: 100%;
		border-left: .01rem solid #E0E0E0;
		position: absolute;
		left: 0;
	}
	.abs div {
		width: 50%;
		height: .49rem;
		line-height: .49rem;
		text-align: center;
		position: relative;
	}
	/* 
	#allmap {
		width: 100%;
		height: 15rem;
	} */
</style>
